#ifndef __DECODER_H__
#define __DECODER_H__

#include "main.h"

#define LED HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, GPIO_PIN_SET)
#define LED_NONE HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, GPIO_PIN_RESET)

#define DECODER_MAX_BIT 138

struct Decoder {
  uint16_t period[DECODER_MAX_BIT];
  uint16_t index;

  uint16_t cnt;
  uint32_t data[DECODER_MAX_BIT / 64];
  uint32_t data_buffer[DECODER_MAX_BIT / 64];

  char info[64];

  uint16_t length;
  uint32_t TIME_SHOW;
  uint8_t color_index;
};

extern struct Decoder decoder;

void decoder_init(void);

#endif
